﻿using System;
using System.Runtime.InteropServices;
using Scenario.WorkflowEngine.DataModel.WorkflowProcesses;
using Scenario.WorkflowEngine.DataModel.WorkflowRelevantData;

namespace Scenario.WAPI
{
    public partial class ActivityHelper
    {
        #region get/set attributes

        [DllImport("WAPI.Dll", EntryPoint = "setActivityAttributes", CharSet = CharSet.Ansi)]
        [return: MarshalAs(UnmanagedType.AnsiBStr)]
        private static extern String SetActivityAttributes(String xmlActivity, String xmlAttributes, string sUser, ref Response response);

        [DllImport("WAPI.Dll", EntryPoint = "getActivityAttributes", CharSet = CharSet.Ansi)]
        [return: MarshalAs(UnmanagedType.AnsiBStr)]
        private static extern String GetActivityAttributes(String xmlActivity, String sOwner, ref Response response);

        [DllImport("WAPI.Dll", EntryPoint = "getAttributesFromActivity", CharSet = CharSet.Ansi)]
        [return: MarshalAs(UnmanagedType.AnsiBStr)]
        private static extern String GetAttributes(String processID, String sActivityName, ref Response response);
        
        #endregion

        #region activity list

        [DllImport("WAPI.Dll", EntryPoint = "getActivityList", CharSet = CharSet.Ansi)]
        [return: MarshalAs(UnmanagedType.AnsiBStr)]
        private static extern String GetActivityList(String sUser, ref Response response);

        [DllImport("WAPI.Dll", EntryPoint = "getAllActivityList", CharSet = CharSet.Ansi)]
        [return: MarshalAs(UnmanagedType.AnsiBStr)]
        private static extern String GetAllActivityList(String sUser, ref Response response);

        [DllImport("WAPI.Dll", EntryPoint = "getAllMyActivityList", CharSet = CharSet.Ansi)]
        [return: MarshalAs(UnmanagedType.AnsiBStr)]
        private static extern String GetAllMyActivityList(String sUser, ref Response response);

        [DllImport("WAPI.Dll", EntryPoint = "getActivityListByProcess", CharSet = CharSet.Ansi)]
        [return: MarshalAs(UnmanagedType.AnsiBStr)]
        private static extern String GetActivityListByProcess(String processID, String user, ref Response response);

        [DllImport("WAPI.Dll", EntryPoint = "getActivitiesByProcess", CharSet = CharSet.Ansi)]
        [return: MarshalAs(UnmanagedType.AnsiBStr)]
        private static extern String GetActivitiesByProcess(String processID, ref Response response);

        [DllImport("WAPI.dll", EntryPoint = "getWorkItemList", CharSet = CharSet.Ansi)]
        [return: MarshalAs(UnmanagedType.AnsiBStr)]
        private static extern String GetWorkItemList(String sOwner, ref Response response);

        [DllImport("WAPI.dll", EntryPoint = "getWorkItemListByNotify", CharSet = CharSet.Ansi)]
        [return: MarshalAs(UnmanagedType.AnsiBStr)]
        private static extern String GetWorkItemListByNotify(String sOwner, ref Response response);

        [DllImport("WAPI.dll", EntryPoint = "getWorkItemListNoRunning", CharSet = CharSet.Ansi)]
        [return: MarshalAs(UnmanagedType.AnsiBStr)]
        private static extern String GetWorkItemListNoRunning(String sOwner, ref Response response);

        [DllImport("WAPI.dll", EntryPoint = "getWorkItemListNoRunningByProcess", CharSet = CharSet.Ansi)]
        [return: MarshalAs(UnmanagedType.AnsiBStr)]
        private static extern String GetWorkItemListNoRunningByProcess(String processID, String sOwner, ref Response response);

        [DllImport("WAPI.dll", EntryPoint = "getWorkItemListRunningByProcess", CharSet = CharSet.Ansi)]
        [return: MarshalAs(UnmanagedType.AnsiBStr)]
        private static extern String GetWorkItemListRunningByProcess(String processID, String sOwner, ref Response response);

        [DllImport("WAPI.dll", EntryPoint = "getWorkItemListRunning", CharSet = CharSet.Ansi)]
        [return: MarshalAs(UnmanagedType.AnsiBStr)]
        private static extern String GetWorkItemListRunning(String sOwner, ref Response response);

        [DllImport("WAPI.dll", EntryPoint = "getWorkItemListRunningNoNotify", CharSet = CharSet.Ansi)]
        [return: MarshalAs(UnmanagedType.AnsiBStr)]
        private static extern String GetWorkItemListRunningNoNotify(String sOwner, ref Response response);

        [DllImport("WAPI.dll", EntryPoint = "getWorkItemListCompleted", CharSet = CharSet.Ansi)]
        [return: MarshalAs(UnmanagedType.AnsiBStr)]
        private static extern String GetWorkItemListCompleted(String sOwner, ref Response response);

        #endregion

        #region Activity Operation (Acquire, Assign, etc..)
        
        [DllImport("WAPI.dll", EntryPoint = "acquireActivity")]
        private static extern void AcquireActivity(String xmlActivity, String sOwner, ref Response response);

        [DllImport("WAPI.dll", EntryPoint = "assignActivity")]
        private static extern void AssignActivity(String xmlActivity, String sOwner, ref Response response);

        [DllImport("WAPI.dll", EntryPoint = "doWorkItem")]
        private static extern void DoWorkItem(String xmlActivity, String sOwner, ref Response response);

        [DllImport("WAPI.dll", EntryPoint = "completeWorkItem")]
        private static extern void CompleteWorkItem(String xmlActivity, String sOwner, String sResultCode, ref Response response);

        [DllImport("WAPI.dll", EntryPoint = "completeWorkItemSynch")]
        private static extern void CompleteWorkItemSynch(String xmlActivity, String sOwner, String sResultCode, ref Response response);

        [DllImport("WAPI.dll", EntryPoint = "stopWorkItem")]
        private static extern void StopWorkItem(String xmlActivity, String sOwner, ref Response response);

        [DllImport("WAPI.dll", EntryPoint = "releaseWorkItem")]
        private static extern void ReleaseWorkItem(String xmlActivity, ref Response response);

        [DllImport("WAPI.dll", EntryPoint = "reassignWorkItem")]
        private static extern void ReassignWorkItem(String xmlActivity, String sOwner, ref Response response);

        #endregion

        #region logs

        [DllImport("WAPI.dll", EntryPoint = "getActivityLog", CharSet = CharSet.Ansi)]
        [return: MarshalAs(UnmanagedType.AnsiBStr)]
        private static extern String GetActivityLog(String xmlActivity, String sOwner, ref Response response);

        [DllImport("WAPI.dll", EntryPoint = "getActivityHistoryLog", CharSet = CharSet.Ansi)]
        [return: MarshalAs(UnmanagedType.AnsiBStr)]
        private static extern String GetActivityHistoryLog(String xmlActivity, String sOwner, ref Response response);

        #endregion
    }
}
